import sqlite3

def Regist(dbpath):
    #get the db user information
    conn=sqlite3.connect(dbpath)
    c=conn.cursor()

    while True:
        name=input('Input your Regist name:')
        password=input('Input your password:')
        c.execute("SELECT * FROM users WHERE name=?",[name])
        users=c.fetchall()
        if not users==[]:
            print('%s is registed,please input a new name.\n'%name)
            
        else:
            print('Regist sucessed!')
            c.execute("INSERT INTO users(name,password) VALUES (?,?)",(name,password))
            conn.commit()
            break
        
    #c.execute("SELECT * FROM users")
    #print(c.fetchall()) #show users
    
    c.close()
    conn.close()

if __name__=="__main__":
    dbpath='test.db'
    Regist(dbpath)
